const {getFoodList} = require('../../utils/request')
const {hitsCount} = require('../../utils/cloudRequest')
const {food} = require('../../utils/config')
Page({

    data: {
        loading: null,
        list: []
    },
    // 跳转详情页
    onDetail(event) {
        const id = event.detail
        hitsCount(food, id).then()
        wx.navigateTo({
            url: `../foodDetail/index?id=${id}`
        })
    },
    onLoad(event) {
        this.setData({
            loading: false
        })
        const category = parseInt(event.type)

        getFoodList(category).then(res => {
            this.setData({
                list: res.data,
                loading: true
            })
        })
    },
})